<template>
	<view class="wanl-product margin-lr">
		
		
		
		
		<view class="head" v-if="indexData && indexData.volunteer_activity.length > 0">
			<view class="title">
				<text class="margin-right-sm text-bold">
					志愿者服务
					<image :src="$wanlshop.oss('/uploads/staticImage/images/default/title.png')" mode="widthFix"></image>
				</text>
			</view>
			<view class="text-gray text-sm" @tap="$wanlshop.on('/pages/volunteer/index')">
				<text class="">更多</text>
				<text class="wlIcon-fanhui2"></text>
			</view>
		</view>
		<block v-if="indexData && indexData.volunteer_activity.length > 0">
		<view class="volunteer" v-for="(item,index) in indexData.volunteer_activity" :key="index" @tap="$wanlshop.to(`/pages/volunteer/details?id=${item.id}`)">
			<view class="listItem">
				<image :src="$wanlshop.oss(item.image)" class="itemImg" mode="aspectFill"></image>
				<view class="itemRight">
					<view class="itemRightTitle">{{item.title}}</view>
					<view class="itemRightTitleFlex">
						<view class="iconfont icon-dingweixiao"></view>
						<view class="itemRightText">{{item.address}}</view>
					</view>
					<view class="itemRightText1">招募人数：<text>{{item.crew_num}}</text></view>
					<view class="itemRightText1">活动时间：<text>{{item.duration}}小时</text></view>
				</view>
			</view>
		</view>
		</block>
		
		<view class="head" v-if="indexData && indexData.works_category.length > 0">
			<view class="title">
				<text class="margin-right-sm text-bold">
					社交圈子
					<image :src="$wanlshop.oss('/uploads/staticImage/images/default/title.png')" mode="widthFix"></image>
				</text>
			</view>
			<view class="text-gray text-sm" @tap="$wanlshop.on('/pages/circle')">
				<text class="">更多</text>
				<text class="wlIcon-fanhui2"></text>
			</view>
		</view>
		
		<view class="quanzi" v-if="indexData&&indexData.works_category.length > 0">
			<view @tap="$wanlshop.to('/pages/circle/index?id='+item.id + '&name='+ item.name + '&image=' +item.image)" class="item" v-for="(item,index) in indexData.works_category" :key="index">
				<image :src="$wanlshop.oss(item.image)" mode="aspectFill"></image>
				<text>#{{item.name}}</text>
			</view>
		</view>
		
		<view class="head" v-if="indexData&&indexData.article.length > 0">
			<view class="title">
				<text class="margin-right-sm text-bold">
					健康资讯
					<image :src="$wanlshop.oss('/uploads/staticImage/images/default/title.png')" mode="widthFix"></image>
				</text>
			</view>
			<view class="text-gray text-sm" @tap="$wanlshop.to('/pages/article/list')">
				<text class="">更多</text>
				<text class="wlIcon-fanhui2"></text>
			</view>
		</view>
		<!-- <wanl-empty v-if="indexData.article && indexData.article.length == 0"></wanl-empty> -->
		<view class="news" v-if="indexData&&indexData.article.length > 0">
			<view class="item bg-white flex justify-between align-center margin-bottom-xs" v-for="(item,index) in indexData.article" :key="index" @tap="$wanlshop.to(`/pages/article/details?id=${item.id}&title=${item.title}&type=article`)">
				<view class="left">
					<text class="text-cut-2">{{item.title}}</text>
					<view class="flex justify-between align-center">
						<text>{{item.categroy}}</text>
						<text class="icon-liulan iconfont">{{item.browse}}</text>
						<!-- <text>{{item.createtime.split(' ')[0]}}</text> -->
					</view>
				</view>
				<view class="right" v-if="item.image">
					<image :src="$wanlshop.oss(item.image)" mode="aspectFill"></image>
				</view>
			</view>
		</view>
		<wanl-page-group :shopData="shopData"/>
		<view class="head">
			<view class="title">
				<text class="margin-right-sm text-bold">
					精品推荐
					<image :src="$wanlshop.oss('/uploads/staticImage/images/default/title.png')" mode="widthFix"></image>
				</text>
			</view>
			<view class="text-gray text-sm" @tap="$wanlshop.to('/pages/product/list?type=goods')">
				<text class="">更多</text>
				<text class="wlIcon-fanhui2"></text>
			</view>
		</view>
		<wanl-index-goods v-if="indexData" :dataList="indexData.goods"></wanl-index-goods>
	</view>
</template>
<script>
	export default {
		name: 'wanlPageRecommend',
		props: {
			lower: {
				type: Number,
				default: 0
			},
			shopData: {
				type: Object,
				default () {}
			},
			indexData: {
				type: Object,
				default () {
					return {
						article:[],
						doctor:[],
						goods:[],
						volunteer_activity:[],
						works_category:[],
					}
				}
			}
		},
		data() {
			return {
				dataList: [], //数据
				current_page: 1, //当前页码
				last_page: 1, //总页码
				status: 'loading',
				contentText: {
					contentdown: '下拉加载更多',
					contentrefresh: '疯狂加载中...',
					contentnomore: '我是有底线的'
				}
			};
		},
		created() {
			// this.loadData();
		},
		// watch: {
		// 	lower(newVal, oldVal) {
		// 		this.loadData('lower');
		// 	}
		// },
		methods: {
			async loadData(type) {
				this.status = 'loading';
				// 判断上拉还是下拉
				if (type === 'lower') {
					if (this.current_page >= this.last_page) {
						this.status = 'noMore';
						return false;
					} else {
						this.current_page += 1;
					}
				}
				await uni.request({
					url: '/wanlshop/product/likes',
					data: {
						page: this.current_page
					},
					success: res => {
						if (type === 'lower') {
							this.dataList = this.dataList.concat(res.data.data);
						} else {
							this.dataList = res.data.data;
						}
						this.current_page = res.data.current_page; //当前页码
						this.last_page = res.data.last_page; //总页码
						// 判断是否还有数据
						if (res.data.current_page === res.data.last_page || res.data.total === 0) {
							this.status = 'noMore';
						} else {
							this.status = 'more';
						}
					}
				});
			},
			handleGoods(id) {
				this.$wanlshop.to(`/pages/apps/groups/goods?id=${id}`);
			},
			handleGroups() {
				this.$wanlshop.to(`/pages/apps/groups/index`);
			}
		}
	};
</script>

<style lang="scss">
	.head {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 85rpx;
	
		.title {
			display: flex;
			align-items: center;
	
			text {
				position: relative;
	
				&:nth-child(1) {
					font-size: 34rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #222222;
					line-height: 40rpx;
				}
	
				image {
					position: absolute;
					width: 200rpx;
					bottom: -6rpx;
					left: 20rpx;
				}
			}
		}
	}
	.list {
		.item {
			margin-bottom: 12rpx;
			padding: 26rpx;
			border:10rpx;
			.top {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				.img {
					margin-right: 22rpx;
					position: relative;
					display: flex;
					align-items: center;
					flex-direction: column;
					image {
						width: 96rpx;
						height: 96rpx;
						border-radius: 50rpx;
					}
					text {
						position: absolute;
						bottom: -16rpx;
						display: inline-block;
						width: 66rpx;
						height: 32rpx;
						border-radius: 16rpx;
						font-size: 20rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 400;
						line-height: 32rpx;
						text-align: center;
						color: #FFFFFF;
						background: #ccc;
						z-index: 9;
						&.c {
							color: #FFFFFF;
							background: #4CBD66;
							z-index: 9;
						}
					}
				}
				.info {
					.member {
						text {
							display: inline-block;
							&:nth-child(1) {
								height: 54rpx;
								font-size: 30rpx;
								font-family: PingFang SC-Medium, PingFang SC;
								font-weight: 500;
								color: #333333;
								line-height: 54rpx;
							}
							&:nth-child(2) {
								height: 42rpx;
								font-size: 26rpx;
								font-family: PingFang SC-Medium, PingFang SC;
								font-weight: 400;
								color: #555555;
								line-height: 42rpx;
								margin-left: 12rpx;
								margin-right: 14rpx;
							}
							&:nth-child(3) {
								width: 160rpx;
								height: 44rpx;
								background: #E9F4EB;
								border-radius: 22rpx;
								font-size: 26rpx;
								font-family: PingFang SC-Medium, PingFang SC;
								font-weight: 500;
								color: #4CBD66;
								line-height: 44rpx;
								text-align: center;
							}
						}
					}
					.address {
						font-size: 30rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 400;
						color: #777777;
						line-height: 42rpx;
						margin-top: 8rpx;
						margin-bottom: 6rpx;
					}
				}
			}
			.bottom {
				width: 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 20rpx;
				.left {
					display: flex;
					justify-content: flex-start;
					align-items: flex-start;
					text {
						&:nth-child(1) {
							font-size: 26rpx;
							font-family: PingFang SC-Medium, PingFang SC;
							font-weight: 500;
							color: #333333;
							line-height: 42rpx;
						}
						&:nth-child(2) {
							width: 380rpx;
							font-size: 26rpx;
							font-family: PingFang SC-Medium, PingFang SC;
							font-weight: 500;
							color: #888888;
							line-height: 42rpx;
						}
					}
					view {
						width: 380rpx;
						font-size: 26rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #888888;
						line-height: 42rpx;
					}
				}
				.right {
					display: flex;
					flex-direction: column;
					align-items: flex-end;
					text {
						&:nth-child(1) {
							font-size: 44rpx;
							font-family: DIN-Bold, DIN;
							font-weight: bold;
							color: #E31F1F;
						}
						&:nth-child(2) {
							font-size: 24rpx;
							font-family: PingFang SC-Medium, PingFang SC;
							font-weight: 500;
							color: #666666;
							line-height: 28rpx;
						}
					}
				}
			}
		}
	}
	
	.quanzi {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 20rpx 0;
		.item {
			width: 330rpx;
			height: 140rpx;
			background: rgba(0,0,0,0.3);
			border-radius: 10rpx;
			position: relative;
			display: flex;
			justify-content: center;
			align-items: center;
			text {
				position: absolute;
				font-size: 40rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 56rpx;
				z-index: 9;
			}
			image {
				border-radius: 10rpx;
				width: 330rpx;
				height: 140rpx;
			}
		}
	}
	.news {
		.item {
			padding: 20rpx;
			width: 100%;
			height: 228rpx;
			border-radius: 10rpx;
			.left {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				height: 100%;
				> text {
					width: 374rpx;
					font-size: 30rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 40rpx;
				}
				view {
					text {
						display: inline-block;
						&:nth-child(1) {
							font-size: 22rpx;
							font-family: PingFang SC-Medium, PingFang SC;
							font-weight: 500;
							color: #4CBD66;
							line-height: 34rpx;
							// width: 74rpx;
							padding: 0 10rpx;
							height: 34rpx;
							border-radius: 18rpx;
							border: 1rpx solid #4CBD66;
							text-align: center;
						}
						&:nth-child(2) {
							color: #777777;
							font-size: 26rpx;
							font-family: PingFang SC-Medium, PingFang SC;
							font-weight: 500;
							color: #777777;
							line-height: 30rpx;
							&::before {
								margin-right: 10rpx;
							}
						}
						&:nth-child(3) {
							font-size: 22rpx;
							font-family: PingFang SC-Medium, PingFang SC;
							font-weight: 500;
							color: #888888;
							line-height: 30rpx;
						}
					}
				}
			}
			.right {
				image {
					width: 240rpx;
					height: 190rpx;
					border-radius: 6rpx;
				}
			}
		}
	}
	
	
	.volunteer {
		width: 100%;
		height: 230rpx;
		margin: 10rpx auto;
		background: #fff;
		border-radius: 10rpx;
	
		.listItem {
			padding: 20rpx;
			display: flex;
	
			.itemImg {
				width: 180rpx;
				height: 180rpx;
				border-radius: 6rpx;
			}
	
			.itemRight {
				// width: 372rpx;
				flex: 1;
				height: auto;
				margin-left: 20rpx;
	
				.itemRightTitle {
					font-size: 32rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #333333;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
	
				.itemRightTitleFlex {
					display: flex;
					align-items: center;
					font-size: 26rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #555555;
					margin-top: 6rpx;
	
					.iconfont {
						font-size: 20rpx;
						color: #4CBD66;
						margin-right: 10rpx;
					}
	
					.itemRightText {
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
				}
	
				.itemRightText1 {
					font-size: 28rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #555555;
					margin-top: 12rpx;
					text {
						font-weight: bold;
					}
				}
			}
		}
	}
</style>